//
//  twoPhotosTableViewCell.m
//  Before
//
//  Created by lanou3g on 15/12/1.
//  Copyright © 2015年 sss. All rights reserved.
//

#import "twoPhotosTableViewCell.h"

@implementation twoPhotosTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self makeData];
    }
    return self;
    
}
- (void)makeData
{
    self.backgroundColor = [UIColor clearColor];

    self.myImageView = [[UIImageView alloc] init];
    self.myImageView.layer.cornerRadius = 15;
    self.myImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.myImageView];
    
    self.myTextLabel = [[UILabel alloc] init];
    self.myTextLabel.numberOfLines = 0;
    [self.contentView addSubview:self.myTextLabel];
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.numberOfLines = 0;
    
    [self.contentView addSubview:self.nameLabel];
    
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.font = [UIFont systemFontOfSize:12.0f];
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.numberOfLines = 0;
    [self.contentView addSubview:self.nameLabel];
    
    self.firstImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.firstImageView];
    self.secondImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.secondImageView];
    self.view = [[UIView alloc] init];
    self.view.alpha = 0.1;
    self.view.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.view];
    
    
    
    // 点赞
    self.praiseButton = [CellButton buttonWithType:(UIButtonTypeSystem)];
    [self.praiseButton setBackgroundImage:[UIImage imageNamed:@"praise"] forState:(UIControlStateNormal)];
    [self.praiseButton setBackgroundImage:[UIImage imageNamed:@"r"] forState:(UIControlStateHighlighted)];
    [self.praiseButton addTarget:self action:@selector(buttonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.contentView addSubview:self.praiseButton];
    self.praiseLabel = [[UILabel alloc] init];
    self.praiseLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.praiseLabel];
    
    // 评论
    self.commentButton = [CellButton buttonWithType:(UIButtonTypeSystem)];
    [self.commentButton setTitle:@"评论" forState:(UIControlStateNormal)];
    [self.commentButton addTarget:self action:@selector(commentbuttonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.contentView addSubview:self.commentButton];


    
}
- (void)buttonAction:(CellButton *)sender
{
    [self.delegate praiseButton:sender];
}
- (void)commentbuttonAction:(CellButton * )sender
{
    [self.delegate commentButton:sender];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    // 头像
    self.myImageView.frame = CGRectMake(10,0,50,50);
    // 名字
    self.nameLabel.frame = CGRectMake(70, 0, CGRectGetWidth(self.contentView.frame) - self.myImageView.frame.size.width - 20, 50);
    // 内容
    self.myTextLabel.frame = CGRectMake(60, 60, CGRectGetWidth(self.contentView.frame) - 70, CGRectGetHeight(self.contentView.frame) - 70 - 110 - 30);
    // 图片
    self.firstImageView.frame = CGRectMake(60, CGRectGetMaxY(self.myTextLabel.frame) + 10, 100, 100);
    self.secondImageView.frame = CGRectMake(CGRectGetMaxX(self.firstImageView.frame) + 10, CGRectGetMaxY(self.myTextLabel.frame) + 10, 100, 100);
     self.view.frame = CGRectMake(0, self.contentView.frame.size.height - 4, self.contentView.frame.size.width, 4);
    self.timeLabel.frame = CGRectMake(CGRectGetWidth(self.contentView.frame) - 100, 0, 100, 50);
    
    // 点赞
    self.praiseButton.frame = CGRectMake(CGRectGetMidX(self.contentView.frame), CGRectGetMaxY(self.firstImageView.frame) + 10, 25, 25);
    self.praiseLabel.frame = CGRectMake(CGRectGetMidX(self.contentView.frame) + self.praiseButton.frame.size.width + 5, CGRectGetMaxY(self.firstImageView.frame) + 10, 35, 25);
    // 评论
    self.commentButton.frame = CGRectMake(CGRectGetMidX(self.contentView.frame) + self.praiseButton.frame.size.width + 5 + 30, CGRectGetMaxY(self.firstImageView.frame) + 10, 30, 25);
    

    

    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
